package com.lbb.mall.product.feign;

import com.lbb.common.to.SkuReductionTo;
import com.lbb.common.to.SpuBoundsTo;
import com.lbb.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@FeignClient("mall-coupon")
public interface CouponFeignService {

    /**
     * 流程分析
     * 1、有人调用了这个方法CouponFeignService.saveBounds(spuBoundsTo)
     * 2、这里的@RequestBody将这个对象转化为json
     * 3、找到mall-coupon服务，给/coupon/spubounds/save发送请求
     * 4、对方服务接收到请求，请求体里面有json数据
     *   对方服务的（@RequestBody SpuBoundsEntity spuBounds）将请求体的json转化为SpuBoundsEntity
     * 总结：只要json数据模型兼容，双方服务无需使用同一个to
     * */
    @RequestMapping(value = "/coupon/spubounds/save",method = RequestMethod.POST)
    R saveBounds(@RequestBody SpuBoundsTo spuBoundsTo);

    @RequestMapping(value = "/coupon/skufullreduction/saveInfo",method = RequestMethod.POST)
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
